package com.woniu.controller.medicalService;

import com.github.pagehelper.PageInfo;
import com.woniu.model.gh.common.Result;
import com.woniu.service.medicalService.IDockerService;
import com.woniu.model.medicalService.entity.Docker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

//医生表
@RestController
@RequestMapping("/ms_docker")
public class DockerController {

    @Autowired
    private IDockerService dockerService;

    //分页 条件查询
    @PostMapping("/findPageByCondition")
    public Result<PageInfo<Docker>> findPageByCondition(@RequestBody Map<String,Object> condition) {
        PageInfo<Docker> page = dockerService.findPageByCondition(condition);
        return Result.ok(page);
    }

    //添加医生
    @PostMapping("/save")
    public Result<Void> save(@RequestBody Docker docker) {
        dockerService.save(docker);
        return Result.ok();
    }

    //删除医生
    @DeleteMapping("/delete")
    public Result<Void> delete(Long id) {
        dockerService.removeById(id);
        return Result.ok();
    }

    //更改上下架
    @PostMapping("/updateBoole")
    public Result<Void> updateBoole(@RequestBody Docker docker) {
        if (docker.getBoole() == 0L)
            docker.setBoole(1L);
        if (docker.getBoole() == 1L)
            docker.setBoole(0L);
        dockerService.updateById(docker);
        return Result.ok();
    }

}
